package com.shell.provider;

import com.shell.bee.base.utils.StringUtil;
import com.shell.customer.accreditation.vo.UserVo;
import com.shell.customer.cfca.service.CfcaAuthTxService;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CfcaAuthUserAcctProvider {
	@Autowired
	private CfcaAuthTxService cfcaAuthTxService;

	@RequestMapping({ "/authCfcauserAcct" })
	public Map<String, String> authCfcauserAcct(String userName, String phoneNo, String idNo, String certType) {
		if ((StringUtil.notEmpty(userName)) && (StringUtil.notEmpty(phoneNo)) && (StringUtil.notEmpty(idNo))) {
			Map<String, String> ret = new HashMap();
			UserVo userVo = new UserVo();
			userVo.setUserName(userName);
			userVo.setPhoneNo(phoneNo);
			userVo.setCertNo(idNo);
			userVo.setCertType(certType);
			String msg;
			try {
				msg = this.cfcaAuthTxService.authUser(userVo);
			} catch (Exception e) {
				e.printStackTrace();
				msg = e.getMessage();
			}
			if (StringUtil.emptyAndNull(msg)) {
				ret.put("errorCode", "0");
			} else {
				ret.put("errorCode", "1");
			}
			ret.put("msg", msg);
			return ret;
		}
		return null;
	}
}
